package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.AgedmallLeaseHtmlMapper;
import org.linlinjava.litemall.db.domain.AgedmallLeaseHtml;
import org.linlinjava.litemall.db.domain.AgedmallLeaseHtmlExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AgedmallLeaseHtmlService {
    @Resource
    private AgedmallLeaseHtmlMapper agedmallLeaseHtmlMapper;

    public List<AgedmallLeaseHtml> getByType(Integer storeId, Integer goodsId, String type) {
        AgedmallLeaseHtmlExample example = new AgedmallLeaseHtmlExample();
        example.or().andDeletedEqualTo(false)
                .andStoreIdEqualTo(storeId)
                .andGoodsIdEqualTo(goodsId)
                .andDescTypeEqualTo(type);
        return agedmallLeaseHtmlMapper.selectByExample(example);
    }

    public AgedmallLeaseHtml getOneByType(Integer storeId, Integer goodsId, String type) {
        List<AgedmallLeaseHtml> list = getByType(storeId, goodsId, type);
        return list.size() > 0 ? list.get(0) : null;
    }

    public List<AgedmallLeaseHtml> getByStoreIdAndGoodsId(Integer storeId, Integer goodsId) {
        AgedmallLeaseHtmlExample example = new AgedmallLeaseHtmlExample();
        example.or().andDeletedEqualTo(false)
                .andStoreIdEqualTo(storeId)
                .andGoodsIdEqualTo(goodsId);
        return agedmallLeaseHtmlMapper.selectByExample(example);
    }

}
